export default {
  data() {
    return {
      // 查询数据
      queryParams: {
        page: 1,
        size: 10
      },
      // 分页结果
      pageData: {
        total: 0,
        rows: []
      },
      // 表单多选对象
      mutilrows: [],
      // 表单多选主键的值
      ids: [],
      // 修改按钮是否禁用
      single: true,
      // 删除按钮是否禁用
      multiple: true
    }
  },
  methods: {
    // 搜索
    handleQuery() {
      this.queryParams.page = 1
      this.fetchData()
    },
    // 查询重置
    resetQuery() {
      this.$refs['queryForm'].resetFields()
      this.fetchData()
      this.disa1 = false
      this.disa2 = false
    },
    handleSizeChange(val) {
      this.queryParams.page = 1
      this.queryParams.size = val
      this.fetchData()
    },
    handleCurrentChange(val) {
      this.queryParams.page = val
      this.fetchData()
    },
    // 表格多选改变事件
    handleSelectionChange(val) {
      this.mutilrows = val
      this.ids = val.map(p => p.id)
      // 删除按钮
      this.multiple = !(val.length > 0)
      if (val.length === 1) {
        // const result = this.ids.some(p => p === 1)
        this.single = false
      } else {
        this.single = true
      }
    }
  },
  created() {
    this.dictType=this.$route.query.dictType
    this.fetchData()
  }
}
